﻿#region Using Directives

using System;
using System.Web.Caching;
using System.Web.Security;
using System.Collections.Generic;

using QuickDev.Common.Serialization;
using QuickDev.Common.Caching.Manager;

using QuickDev.Model;
using QuickDev.SQLServerDAL;

#endregion

namespace QuickDev.Caching
{
    /// <summary>
    /// Cache Layer For dbo.SYS_CurrencyCode.
    /// </summary>
    public class CurrencyCodeCache
    {
        #region Constants

        private const string CurrencyCodeCollectionCacheKey = "_CurrencyCode_Collection_";

        #endregion

        #region Refresh Cache

        /// <summary>
        /// Refreshes the collection in the cache.
        /// This will make that the collection should reinsert itself on the next page request
        /// </summary>
        public static void RemoveCollectionFromCache()
        {
            CacheHelper.RemoveCacheObject<string>( CurrencyCodeCollectionCacheKey );
        }

        /// <summary>
        /// Refreshes the collection in the cache.
        /// This will make that the collection should reinsert itself on the next page request
        /// </summary>
        public static void RemoveAllCollectionFromCache()
        {
            CacheHelper.RemoveAllCacheObjectStartWith( CurrencyCodeCollectionCacheKey );
        }

        #endregion

        #region CurrencyCodeCache.GetList() Method

        /// <summary>
        /// public IList(CurrencyCode) GetList()
        /// </summary>
        /// <returns>IList(CurrencyCode)</returns>
        public static List<CurrencyCode> GetList()
        {
            return CacheHelper.CacheObject<List<CurrencyCode>>
            (
                delegate
                {
                    return CurrencyCodeDAL.GetList();
                },
                CurrencyCodeCollectionCacheKey,
                CacheLength.GetLongCacheTime,
                CacheItemPriority.High
            );
        }
        #endregion
    }
}

